package com.app.Controller;

import com.app.Activity.HelloForm1;
import com.app.Activity.frmBieuQuyetMoiRoiNhom;
import com.app.Activity.frmMainActivity;

import com.app.Activity.frmNotificationMoiVaoNhom;


import com.app.Activity.trucActivity;


import com.app.Activity.frmPhuActivity;
import com.app.Activity.trucActivity;


import android.app.Activity;
import android.app.AlertDialog;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;

import android.content.Context;
import android.content.Intent;

import android.os.Handler;
import app.com.ModuleRole.R;

public class ActivityController {
	public static Activity peerActivity=null;
	//public static String mess;
	public  static Handler hander=new Handler();
	public static void showGroupInvite(){
		hander.post(new Runnable() {
			
			@Override
			public void run() {
				frmPhuActivity.show("Co nguoi moi ban vao nhom");
				
			}
		});
	}
	public static void showError(){
		frmPhuActivity.show("Bạn ko có quyền này");
	}
	public static void showMoiVaoNhomNotif() {
		hander.post(frmPhuActivity.raMoiVaoNhomNotif);
	}
	public static void setPeerActivity(Activity peerActivity) {
		ActivityController.peerActivity = peerActivity;
	}

	public static void showNotification(String title, String contentTitle, String contentText){
		Intent intent = new Intent(peerActivity, frmNotificationMoiVaoNhom.class);
		intent.putExtra("ID", 1);
		PendingIntent pendingIntent = PendingIntent.getActivity(peerActivity, 0,
				intent, 0);
		NotificationManager notiManager = (NotificationManager) peerActivity.getSystemService(peerActivity.getBaseContext().NOTIFICATION_SERVICE);
		Notification notif = new Notification(R.drawable.ic_launcher,
				title, System.currentTimeMillis());
		notif.setLatestEventInfo(peerActivity, contentTitle, contentText,
				pendingIntent);

		notiManager.notify(1, notif);		

	}
	
	//=============================================truc==================================
	public static void ShowMessage(final String message){
		trucActivity.message=message;
		hander.post(trucActivity.showMessage);
	}
	
	//hien thi noi dung chat
	
	public static void ShowChatMessage(final String message,final String address){
		trucActivity.chatMessage=message;
		trucActivity.address=address;
		hander.post(trucActivity.showChatMessage);
	}
	
	public static void DislayKickMember(){
		hander.post(trucActivity.dislayKickMember);
		
	}
	
	public static void ShowFrm2(){
		hander.post(HelloForm1.showFrm2);
	}
	
	public static void ShowFrm1(){
		hander.post(trucActivity.showForm1);
	}
	
	public static void ShowResultVote(){
		hander.post(trucActivity.showResultVoteKick);
	}
	
	public static void FinishDiscussActivity(){
		hander.post(trucActivity.finishAct);
	}
	
	public static void DoEndTime(){
		
		hander.post(frmBieuQuyetMoiRoiNhom.doEndTime);
	}
	
	public static void SetTimeVote(final int time){
		frmBieuQuyetMoiRoiNhom.timeVoteKick=time;
	}
	//===============================truc=================================
	
	
	
	
	
	
	
	
	
	
}
